import ShaderLib from "../ShaderLib";

export default class RippleCylinderShader {
    public static getVertexShader() {
        return ShaderLib.getDefaultVertexShader();
    }

    public static getFragmentShader() {
        let shader = `
            #include <common>
            #include <fog_pars_fragment>
            #include <logdepthbuf_pars_fragment>       
            varying vec2 uvTexcoord;
            uniform float time;
            uniform vec3 v_color;
            uniform float radius;
            uniform float height;
            uniform float num;
            #define PIValue 3.14159265359

            void main(){
                vec2 uv = uvTexcoord;
                vec4 fragColor = vec4(0.);
                float sin = sin((uv.y+0.5 - time)*PIValue*(2.0*num));
                float high = 0.8;
                float medium = 0.4;
                if (sin > high) {
                 fragColor = vec4(mix(vec3(.8, 1., 1.), v_color.rgb, (1. - sin) / (1. - high)), 1.);
                } else if(sin > medium) {
                  fragColor = vec4(v_color.rgb, mix(1., 0.15, 1.-(sin - medium) / (high - medium)));
                } else {
                  fragColor = vec4(v_color.rgb, 0.15);
                }

                vec3 fade = vec3(smoothstep(0.7, 0.4, clamp(-(1. - uv.y) * .25 + .8, 0., .75)), v_color.g, v_color.b);

				fragColor += vec4(fade, fade.x * 2.0); 
                fragColor.a = 0.5;
                gl_FragColor = fragColor;
                #include <fog_fragment>
            }
        `;
        return shader;
    }

}
